<?php

declare(strict_types=1);

namespace App\Model;

use Hyperf\DbConnection\Model\Model;

/**
 * 超过免费私聊数量的用户记录
 */
class UserPassChatlmt extends Model
{
    protected $table = 'user_pass_chat_lmt';
    protected $fillable = ['user_id', 'lmt_msg_num', 'device_id', 'flag'];

    static function addRecord($userId = 0, $deviceId = '', $msgNum = 1)
    {
        return self::updateOrCreate(['user_id' => $userId], [
            'user_id' => $userId,
            'device_id' => $deviceId,
            'lmt_msg_num' => $msgNum,
            'flag' => 1
        ]);
    }
}
